package org.example.springbook.dao;

import org.example.springbook.model.BookInfo;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
// 数据处理层
@Repository
public class BookDao {
    // 虚拟数据
    public List<BookInfo> mockBook() {

        // 通常情况下从数据库中拿数据
        // 这里使用 mock数据
        List<BookInfo> books = new ArrayList<>();
        for(int i = 1; i <= 20; i++) {
            BookInfo book = new BookInfo();
            book.setId(i);
            book.setBookName("书名" + i);
            book.setAuthor("作者" + i);
            book.setPrice(new BigDecimal(new Random().nextInt(100)));
            book.setCount(new Random().nextInt(50) + 5);
            book.setPublish("出版社" + i);
            book.setStatus(1);
            books.add(book);
        }
        return books;
    }
}
